<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">
    <f:view contentType="text/html" locale="#{languageBean.currentLocale}">    
        <h:head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
            <title><ui:insert name="title">#{commonMsg['title']}</ui:insert></title>
            <style type="text/css">
                .ui-widget {
                    font-family: Tahoma;
                    font-size: 11.5px;
                }
            </style>
        </h:head>
        <h:body>
            <h:outputStylesheet library="css" name="component.css"/>
            <h:outputStylesheet library="css" name="mainLayout.css"/>
            <ui:insert name="idleMonitor">
                <h:form id="monitorForm" prependId="false">
                    <p:idleMonitor timeout="#{session.maxInactiveInterval * 1000}" onidle="idleDialog.show();" 
                                   onactive='window.location = "#{request.contextPath}/index.jsf";'/>

                    <p:dialog header="#{commonMsg['monitor']}" resizable="false" widgetVar="idleDialog" modal="true" width="400">
                        <h:outputText value="#{commonMsg['msg.sessionTimeout']}" />
                    </p:dialog>
                </h:form>
            </ui:insert>

            <div id="container">
                <div id="header">
                    <h:form id="headerForm" prependId="false">
                        <h:panelGrid columns="2" width="100%">
                            <h1 style="color: white;">
                                VFriends ID
                            </h1>
                            <h:panelGroup style="margin-right: 10px; float: right;">
                                <p:commandLink action="#{languageBean.changeLanguageAction()}" ajax="false">
                                    <h:graphicImage value="#{resource['images:us.png']}" alt="EN" style="padding-right: 8px; border: 0px;"/>
                                    <f:setPropertyActionListener target="#{languageBean.language}" value="en" />
                                </p:commandLink>
                                <p:commandLink action="#{languageBean.changeLanguageAction()}" ajax="false">
                                    <h:graphicImage value="#{resource['images:vn.png']}" alt="VN" style="padding-right: 12px; border: 0px;"/>
                                    <f:setPropertyActionListener target="#{languageBean.language}" value="vi" />
                                </p:commandLink>
                                
                                <h:outputText value="#{securityBean.loggedUser.fullName == '' || securityBean.loggedUser.fullName == null ? securityBean.loggedUser.username : securityBean.loggedUser.fullName}" 
                                              style="padding-left: 10px; color: white;" rendered="#{securityBean.loggedUser != null}"/>
                                <p:commandLink id="logout" action="#{securityBean.logoutAction()}" ajax="false" value="#{commonMsg['logout']}" style="padding-left: 10px; color: white;" rendered="#{securityBean.loggedUser != null}"/>
                                <p:commandLink id="login" action="/openid" ajax="false" value="#{commonMsg['login']}" style="padding-left: 10px; color: white;" rendered="#{securityBean.loggedUser == null}"/>
                                <h:outputLink value="register.jsf" style="padding-left: 10px; color: white;" rendered="#{securityBean.loggedUser == null}">
                                    #{commonMsg['register']}
                                </h:outputLink>
                            </h:panelGroup>
                        </h:panelGrid>
                    </h:form>
                </div>
                <ui:insert name="navigation"></ui:insert>
                <div id="content-container">
                    <h:form id="statusForm" prependId="false">
                        <p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>  

                        <p:dialog modal="false" widgetVar="statusDialog" header="#{commonMsg['status']}"   
                                  draggable="false" closable="false">  
                            <p:graphicImage value="#{resource['images:ajaxloadingbar.gif']}" />  
                        </p:dialog>
                    </h:form>
                    <div id="content">
                        <p:layout style="min-width: 100%; min-height: 600px; height: 600px;" >
                            <p:layoutUnit position="west" header="Menu" collapsible="true" size="200" minSize="200" resizable="false" rendered="#{securityBean.loggedUser != null}">
                                <h:form id="menuForm">
                                    <p:menu style="width: 90%; margin-top: 2px; margin-left: auto; margin-right: auto;">  
                                        <p:submenu label="Thông tin cá nhân" rendered="#{securityBean.isUserInRole('CUSTOMER')}">  
                                            <p:menuitem value="Thông tin tài khoản" url="/account/profile.jsf" ajax="false"/>  
                                            <p:menuitem value="Đổi mật khẩu" url="/account/changepass.jsf" ajax="false" rendered="#{!securityBean.loggedUser.external}"/>
                                            <p:menuitem value="Quản lý giao dịch VXu" url="http://payment.vfriends.vn" ajax="false"/>
                                        </p:submenu>  
                                        <p:submenu label="Quản trị hệ thống" rendered="#{securityBean.isUserInRole('ADMINISTRATOR')}">  
                                            <p:menuitem value="Quản lý người dùng" url="/admin/user/list.jsf" ajax="false"/>
                                            <p:menuitem value="Quản lý nhóm người dùng" url="/admin/group/list.jsf" ajax="false"/>
                                            <p:menuitem value="Quản lý quyền truy cập" url="/admin/role/list.jsf" ajax="false"/>
                                            <p:menuitem value="Quản lý trang web" url="/admin/page/list.jsf" ajax="false"/>
                                        </p:submenu>
                                    </p:menu>
                                </h:form>
                            </p:layoutUnit>
                            <p:layoutUnit position="center">
                                <ui:insert name="content"></ui:insert>
                            </p:layoutUnit>
                        </p:layout>
                    </div>
                    <div id="footer" style="color: white;">
                        Copyright © VFriends, 2012
                    </div>
                </div>
            </div>
        </h:body>
    </f:view>    
</html>
